﻿using SSCAI.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSCAI.Client.Models
{
    public class LotteryModel
    {
        public int Id { get; set; }
        public string Issue { get; set; }
        public string WinningNumber { get; set; }

        public string ModifiedTime { get; set; }

        /// <summary>
        /// 从大到小排列--左到右 4321
        /// </summary>
        public string BigToSmall
        {
            get
            {
                return string.Join(string.Empty,
                    CalculateHelper.QickSort(
                                                    new int[] { 
                                                    this.One, 
                                                    this.Two, 
                                                    this.Three, 
                                                    this.Four }
                                                ));
            }
        }

        /// <summary>
        /// 从小到大排列--左到右 1234
        /// </summary>
        public string SmallToBig
        {
            get
            {
                return string.Join(string.Empty,
                    CalculateHelper.QickSort(
                                                    new int[] { 
                                                    this.One, 
                                                    this.Two, 
                                                    this.Three, 
                                                    this.Four },
                                                    1
                                                ));
            }
        }

        /// <summary>
        /// 012路
        /// </summary>
        public string ZeroOneTwoNumber
        {
            get
            {
                return string.Concat(this.Four % 3, this.Three % 3, this.Two % 3, this.One % 3);
            }
        }

        /// <summary>
        /// 0123路
        /// </summary>
        public string ZOTTFNumber
        {
            get
            {
                return string.Concat(this.Four % 5, this.Three % 5, this.Two % 5, this.One % 5);
            }
        }

        /// <summary>
        /// 01234路
        /// </summary>
        public string ZOTTNumber
        {
            get
            {
                return string.Concat(this.Four % 4, this.Three % 4, this.Two % 4, this.One % 4);
            }
        }

        /// <summary>
        /// 4D号码
        /// </summary>
        public string FourDNumber
        {
            get
            {
                return this.WinningNumber.Substring(1, 4);
            }
        }

        /// <summary>
        /// 4D和值
        /// </summary>
        public int FourDSum
        {
            get
            {
                return this.One + this.Two + this.Three + this.Four;
            }
        }

        /// <summary>
        /// 个位
        /// </summary>
        public int One
        {
            get
            {
                return Convert.ToInt16(this.WinningNumber.Substring(4, 1));
            }
        }

        /// <summary>
        /// 十位
        /// </summary>
        public int Two
        {
            get
            {
                return Convert.ToInt16(this.WinningNumber.Substring(3, 1));
            }
        }

        /// <summary>
        /// 百位
        /// </summary>
        public int Three
        {
            get
            {
                return Convert.ToInt16(this.WinningNumber.Substring(2, 1));
            }
        }

        /// <summary>
        /// 千位
        /// </summary>
        public int Four
        {
            get
            {
                return Convert.ToInt16(this.WinningNumber.Substring(1, 1));
            }
        }

        /// <summary>
        /// 万位数字
        /// </summary>
        public int Five
        {
            get
            {
                return Convert.ToInt16(this.WinningNumber.Substring(0, 1));
            }
        }

        /// <summary>
        /// 4d 跨度 比如 开奖号 *7641 跨度 1，2，3，6
        /// </summary>
        public string FourDSpan
        {
            get
            {
                return string.Concat(
                                        Math.Abs(this.Four - this.Three).ToString(),
                                        ",",
                                        Math.Abs(this.Three - this.Two).ToString(),
                                        ",",
                                        Math.Abs(this.Two - this.One).ToString(),
                                        ",",
                                        Math.Abs(this.Four - this.One).ToString()
                                     );
            }
        }

    }
}
